﻿#ifndef XREGISTER_H
#define XREGISTER_H

#include <QObject>
#include "xnamespace.h"

QT_BEGIN_NAMESPACE

class XRegisterPrivate;
class XRegister : public QObject
{
    Q_OBJECT

    Q_PROPERTY(DeviceType deviceType READ getDeviceType WRITE setDeviceType NOTIFY deviceTypeChanged)
    Q_PROPERTY(int deviceNumber READ getDeviceNumber WRITE setDeviceNumber NOTIFY deviceNumberChanged)
    Q_PROPERTY(RegistersObjectType objectType READ getObjectType WRITE setObjectType NOTIFY objectTypeChanged)
    Q_PROPERTY(int objectNumber READ getObjectNumber WRITE setObjectNumber NOTIFY objectNumberChanged)
    Q_PROPERTY(ValueType valueType READ getValueType WRITE setValueType NOTIFY valueTypeChanged)
    Q_PROPERTY(double registerValue READ getRegisterValue WRITE setRegisterValue NOTIFY registerValueChanged)

public:
    explicit XRegister(QObject *parent = nullptr);
    ~XRegister();

    /* Property Interface */
    DeviceType getDeviceType() const;
    void setDeviceType(DeviceType);

    int getDeviceNumber() const;
    void setDeviceNumber(int);

    RegistersObjectType getObjectType() const;
    void setObjectType(RegistersObjectType);

    int getObjectNumber() const;
    void setObjectNumber(int);

    ValueType getValueType() const;
    void setValueType(ValueType);

    double getRegisterValue() const;
    void setRegisterValue(double);

signals:
    void deviceTypeChanged(DeviceType);
    void deviceNumberChanged(int);
    void objectTypeChanged(CoilObjectType);
    void objectNumberChanged(int);
    void valueTypeChanged(ValueType);
    void registerValueChanged(double);

private:
    Q_DISABLE_COPY(XRegister)
    XRegisterPrivate *xRegisterP = nullptr;
};

QT_END_NAMESPACE

#endif // XREGISTER_H
